<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改产品系列')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-edit" th:object="${proLine}">
        <input id="lineId" name="lineId" type="hidden" th:field="*{lineId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">产品系列名称</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="lineName" id="lineName" th:field="*{lineName}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">产品系列备注：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="lineRemark" id="lineRemark" th:field="*{lineRemark}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">显示顺序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="lineSort" id="lineSort" th:field="*{lineSort}" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "pro/line";

    $("#form-post-edit").validate({
        onkeyup: false,
        rules:{
            postName:{
                remote: {
                    url: prefix+ "/checkLineNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "lineId": function() {
                            return $("input[name='typeId']").val();
                        },
                        "lineName" : function() {
                            return $.common.trim($("#lineName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },

            postSort:{
                digits:true
            },
        },
        messages: {

            "lineName": {
                remote: "产品系列名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
        }
    }
</script>
</body>
</html>
